package com.gongj.shej.demo;

import jdk.nashorn.internal.ir.IfNode;

/**
 * @program: shej
 * @description: 抽象工厂模式
 * @author: gongj
 * @Description: TODO
 * @create: 2020-07-22 15:08
 **/
public interface AbstractFactory {
    IFood createFood();
    IPhone createPhone();
    public static void main(String[] args) {
        Pizza3Factory pizza3Factory = new Pizza3Factory();
        Hamburger3Factory hamburger3Factory = new Hamburger3Factory();
        pizza3Factory.createFood().makeFood();
        hamburger3Factory.createFood().makeFood();
        hamburger3Factory.createPhone().makePhone();
    }
}
interface IPhone{
    void makePhone();
}

interface IFood{
    void makeFood();
}

class Pizza3Factory implements AbstractFactory{

    @Override
    public IFood createFood() {
        return new Pizza3();
    }

    @Override
    public IPhone createPhone() {
        return new XiaoMi();
    }
}
class Hamburger3Factory implements AbstractFactory{

    @Override
    public IFood createFood() {
        return new Hamburger3();
    }

    @Override
    public IPhone createPhone() {
        return new XiaoMi();
    }
}

class Pizza3 implements IFood{

    @Override
    public void makeFood() {
        System.out.println("制作具体产品-披萨");
    }
}

class Hamburger3 implements IFood{

    @Override
    public void makeFood() {
        System.out.println("制作具体产品-汉堡");
    }
}

class XiaoMi implements IPhone{

    @Override
    public void makePhone() {
        System.out.println("制作具体产品手机-小米");
    }
}